package cn.tutu.shop.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.tutu.shop.dao.ExpressDao;
import cn.tutu.shop.entity.Express;
import cn.tutu.shop.service.ExpressService;

@Service
@Transactional
public class ExpressServiceImpl implements ExpressService {

	@Autowired
	private ExpressDao expressDao;

	@Override
	public void create(Express express) {
		expressDao.insert(express);
	}

	@Override
	public void modify(Express express) {

		expressDao.update(express);
	}

	@Override
	public void remove(String id) {
		expressDao.delete(id);
	}

	@Override
	public List<Express> getByUser(String userId) {
		// TODO Auto-generated method stub

		List<Express> list = expressDao.findByUser(userId);
		for (Express e : list) {
			String[] node = e.getRegion().getTreeNode().split("\\|");
			e.setProvince(node[0]);
			e.setCity(node[1]);
		}
		return list;
	}

}
